package com.fametal.ui.activity;

import com.fametal.R;
import com.fametal.GlobalConstant.Settings;
import com.fametal.ui.utils.Utils;

import android.app.Activity;
import android.app.ActivityGroup;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;

public class TVControlOneActivity extends Activity {

	private ActivityGroup mGroup;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.tv_control_one);
		mGroup = (ActivityGroup)getParent();
	}

	private boolean poweroff = true;
	public void onClick(View view) {
		String operation = null;
		switch (view.getId()) {
		case R.id.tv_two_control:
			LinearLayout container = (LinearLayout) mGroup.getWindow().findViewById(R.id.tv_control_container);
			mGroup.getLocalActivityManager().removeAllActivities();
			Utils.setActivityContent(mGroup, "tv", container, TVControlTwoActivity.class);
			break;
		case R.id.tv_power:
			Button bt = (Button)view;
			if(poweroff == true){
				bt.setText(getResources().getString(R.string.poweroff));
				operation = "poweron";
				poweroff = false;
			}else{
				bt.setText(getResources().getString(R.string.power));
				operation = "poweroff";
				poweroff = true;
			}
			break;
		case R.id.tv_mode:
			operation = "mode";
			break;
		case R.id.tv_menu:
			operation = "menu";
			break;
		case R.id.tv_back:
			operation = "back";
			break;
		case R.id.tv_signal_source:
			operation = "signal";
			break;
		case R.id.tv_mute:
			operation = "mute";
			break;
		case R.id.tv_review:
			operation = "review";
			break;
			
		case R.id.tv_one:
			operation = "1";
			break;
		case R.id.tv_two:
			operation = "2";
			break;
		case R.id.tv_three:
			operation = "3";
			break;
		case R.id.tv_four:
			operation = "4";
			break;
		case R.id.tv_five:
			operation = "5";
			break;
		case R.id.tv_six:
			operation = "6";
			break;
		case R.id.tv_seven:
			operation = "7";
			break;
		case R.id.tv_eight:
			operation = "8";
			break;
		case R.id.tv_nine:
			operation = "9";
			break;
		case R.id.tv_ten:
			operation = "+10";
			break;
		case R.id.tv_zero:
			operation = "0";
			break;
		case R.id.tv_program_increase:
			operation = "programincrease";
			break;	
		case R.id.tv_volume_increase:
			operation = "volumeincrease";
			break;	
		case R.id.tv_ok:
			operation = "ok";
			break;	
		case R.id.tv_volume_decrease:
			operation = "volumedecrease";
			break;	
		case R.id.tv_program_decrease:
			operation = "programdecrease";
			break;	
		}
		if(operation != null && !operation.equals("")){
			String url = Settings.IP + "cgi-bin/TV1_control.cgi?operation=" + operation;
			Utils.get(getParent(), url, false);
		}
	}
}
